//
//  AboutUsController.m
//  BCNADemo
//
//  Created by 马东朝 on 2018/5/16.
//  Copyright © 2018年 马东朝. All rights reserved.
//

#import "AboutUsController.h"
#define CellInd @"cell"
@interface AboutUsController ()<UITableViewDelegate, UITableViewDataSource>
{
    UITableView *tableView;
    UILabel * updateText;
    
}
@end

@implementation AboutUsController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addLogoViews];
    [self addTableView];
}
- (void)addLogoViews{
    
    UIImageView *logoImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kHeight(260) * 131/169, kHeight(260))];
    logoImage.center = CGPointMake(ScreenWidth/2, kHeight(390));
    logoImage.image = [UIImage imageNamed:@"LOGO@3x.png"];
    [self.view addSubview:logoImage];
    UILabel * logoText = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(logoImage.frame) + kHeight(20), ScreenWidth, kHeight(60))];
    logoText.center = CGPointMake(kScreenWidth/2 + kWidth(16), CGRectGetMaxY(logoImage.frame) + kHeight(60));
    [self.view addSubview:logoText];
    logoText.text = @"Welcone to Golink";
    logoText.font = [UIFont systemFontOfSize:kHeight(80)];
    logoText.textColor = [UIColor whiteColor];
    logoText.textAlignment = NSTextAlignmentCenter;
    
     updateText= [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(logoText.frame) + kHeight(20), ScreenWidth, kHeight(60))];
    updateText.center = CGPointMake(kScreenWidth/2 + kWidth(16), CGRectGetMaxY(logoText.frame) + kHeight(60));
    [self.view addSubview:updateText];
    updateText.text = [NSString stringWithFormat:@"v 1.0.1 %@20180601", StringWithKey(@"AboutUs0")];
    updateText.font = [UIFont systemFontOfSize:kHeight(36)];
    updateText.textColor = [UIColor whiteColor];
    updateText.textAlignment = NSTextAlignmentCenter;
}
- (void)addTableView{
    
    tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(updateText.frame) + kHeight(240), ScreenWidth, ScreenHeight -CGRectGetMaxY(self.but.frame) - kHeight(240)) style:UITableViewStylePlain];
    tableView.scrollEnabled = NO;
    tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:tableView];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellInd];
    tableView.rowHeight = kHeight(180);
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}
#pragma mark -- UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellInd];
    if (indexPath.row < 2) {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    NSString *textStr = [NSString stringWithFormat:@"AboutUs%ld", indexPath.row + 1];
    cell.textLabel.text = StringWithKey(textStr);
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
        {
            [self getHtml5VCWithURL:@"/about"];
        }
            break;
        case 1:
        {
            if (__IPHONE_10_3){
                //一句话实现在App内直接评论了。然而需要注意的是：打开次数一年不能多于3次。（当然开发期间可以无限制弹出，方便测试）
                [SKStoreReviewController  requestReview];
            }
            else{
                AlterView(StringWithKey(@"ALter0"), StringWithKey(@"sss"), StringWithKey(@"ALter8"));
            }
        }
            break;
        case 2:
        {
            
        }
            break;
        case 3:
        {
            
        }
            break;
            
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)getHtml5VCWithURL:(NSString *)URL{
    NSLog(@"%@", [NSString stringWithFormat:@"%@%@", UrlAddress, URL]);
    WebViewController *webVC = [[WebViewController alloc] init];
    webVC.url =[NSString stringWithFormat:@"%@%@", UrlAddress, URL];
    [self.navigationController pushViewController:webVC animated:YES];
    //    [GLHttpTool postWITHJSON:[NSString stringWithFormat:@"%@%@", UrlAddress, URL] params:nil success:^(id responseObj) {
    //        NSLog(@"responseObj==%@", responseObj);
    //
    //    } failure:^(NSError *error) {
    //        NSLog(@"error==%@", error);
    //    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
